﻿using System;
using ProjScan.Tools;
using UnityEditor;
using UnityEngine;

namespace ProjScan.RecordManager.AssetData
{
	// Token: 0x02000291 RID: 657
	internal class AnimationClipAssetData : ImportAssetData<AnimationClip, ModelImporter>
	{
		// Token: 0x06001142 RID: 4418 RVA: 0x00051708 File Offset: 0x0004F908
		public AnimationClipAssetData(int assetPathId, string fileName, AnimationClip clip, ModelImporter importer) : base(assetPathId, fileName, clip, importer)
		{
			bool flag = importer == null;
			if (flag)
			{
				this.noImporter = true;
			}
			else
			{
				this.animationType = importer.animationType;
				this.animationCompression = importer.animationCompression;
				this.resampleCurves = importer.resampleCurves;
				this.fbxClipName = clip.name;
			}
			this.animationClipLength = clip.length;
			this.containsScaleProperty = this.ContainScaleProperty(clip);
			this.containsDecimalValue = this.ContainDecimalValue(clip);
		}

		// Token: 0x06001143 RID: 4419 RVA: 0x00051794 File Offset: 0x0004F994
		public AnimationClipAssetData(int assetPathId, string fileName, string assetPath, AnimationClip clip, ModelImporter importer) : base(assetPathId, fileName, assetPath, clip, importer)
		{
			bool flag = importer == null;
			if (flag)
			{
				this.noImporter = true;
			}
			else
			{
				this.animationType = importer.animationType;
				this.animationCompression = importer.animationCompression;
				this.resampleCurves = importer.resampleCurves;
				this.fbxClipName = clip.name;
			}
			this.animationClipLength = clip.length;
			this.containsScaleProperty = this.ContainScaleProperty(clip);
			this.containsDecimalValue = this.ContainDecimalValue(clip);
		}

		// Token: 0x06001144 RID: 4420 RVA: 0x00051828 File Offset: 0x0004FA28
		private bool ContainScaleProperty(AnimationClip clip)
		{
			bool flag = clip != null;
			if (flag)
			{
				foreach (EditorCurveBinding editorCurveBinding in AnimationUtility.GetCurveBindings(clip))
				{
					bool flag2 = editorCurveBinding.propertyName.ToLower().Contains("scale");
					if (flag2)
					{
						return true;
					}
				}
			}
			return false;
		}

		// Token: 0x06001145 RID: 4421 RVA: 0x0005188C File Offset: 0x0004FA8C
		private bool ContainDecimalValue(AnimationClip animationClip)
		{
			bool flag = animationClip != null;
			if (flag)
			{
				foreach (EditorCurveBinding editorCurveBinding in AnimationUtility.GetCurveBindings(animationClip))
				{
					AnimationCurve editorCurve = AnimationUtility.GetEditorCurve(animationClip, editorCurveBinding);
					bool flag2 = editorCurve != null && editorCurve.keys != null;
					if (flag2)
					{
						Keyframe[] keys = editorCurve.keys;
						int num = 0;
						while (keys != null && num < keys.Length)
						{
							string text = keys[num].value.ToString("F10");
							int num2 = text.IndexOf(".");
							bool flag3 = num2 == -1;
							if (flag3)
							{
								return false;
							}
							for (int j = num2 + 5; j < text.Length; j++)
							{
								bool flag4 = text[j] != '0';
								if (flag4)
								{
									return true;
								}
							}
							num++;
						}
					}
				}
			}
			return false;
		}

		// Token: 0x06001146 RID: 4422 RVA: 0x000519A8 File Offset: 0x0004FBA8
		public override string GetCSVHeader()
		{
			return "Name,DirID,Length,Compression,Type";
		}

		// Token: 0x06001147 RID: 4423 RVA: 0x000519C0 File Offset: 0x0004FBC0
		public override string GetInfo()
		{
			bool noImporter = this.noImporter;
			string result;
			if (noImporter)
			{
				string[] values = new string[]
				{
					ToolsHelper.QuoteString(this.fileName),
					",",
					this.assetPathId.ToString(),
					",",
					this.animationClipLength.ToString(),
					",NULL,NULL"
				};
				result = string.Concat(values);
			}
			else
			{
				string[] values2 = new string[]
				{
					ToolsHelper.QuoteString(this.fileName),
					",",
					this.assetPathId.ToString(),
					",",
					this.animationClipLength.ToString(),
					",",
					this.animationCompression.ToString(),
					",",
					this.animationType.ToString()
				};
				result = string.Concat(values2);
			}
			return result;
		}

		// Token: 0x06001148 RID: 4424 RVA: 0x00051AB4 File Offset: 0x0004FCB4
		public override string GetAssetPath()
		{
			return string.IsNullOrEmpty(this.fbxClipName) ? base.GetAssetPath() : (this.path + "$" + this.fbxClipName);
		}

		// Token: 0x040009FE RID: 2558
		private float animationClipLength;

		// Token: 0x040009FF RID: 2559
		public bool containsScaleProperty;

		// Token: 0x04000A00 RID: 2560
		public bool containsDecimalValue;

		// Token: 0x04000A01 RID: 2561
		public bool resampleCurves;

		// Token: 0x04000A02 RID: 2562
		public ModelImporterAnimationType animationType;

		// Token: 0x04000A03 RID: 2563
		public ModelImporterAnimationCompression animationCompression;

		// Token: 0x04000A04 RID: 2564
		private string fbxClipName;
	}
}
